package com.dmall.manager.controller;

import com.dmall.content.service.ContentCategoryService;
import com.dmall.framework.result.DmallResult;
import com.dmall.utils.EasyUITreeNodeInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 内容分类管理Controller
 * @author Chen 2017/10/22
 */
@Controller
@RequestMapping("/content/category")
public class ContentCatController {
    @Autowired
    private ContentCategoryService contentCategoryService;

    /**
     * 获取分类列表
     * @return
     */
    @RequestMapping(method = RequestMethod.GET )
    @ResponseBody
    public List<EasyUITreeNodeInfo> getContentCatList(@RequestParam(name = "id",defaultValue = "0") Long parentId){
       return contentCategoryService.getContentCatList(parentId);
    }

    /**
     * 添加分类节点
     */
    @RequestMapping(method = RequestMethod.POST)
    @ResponseBody
    public DmallResult createContentCategory(Long parentId,String name){
        return contentCategoryService.addContentCategory(parentId,name);
    }
}
